package 注解3;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class TestDescription {
    public static void main(String[] args) throws NoSuchMethodException {
//        获取person的class反射对象
        Class<Person> personClass = Person.class;
//        判断是否有Description注解反射对象
        if(personClass.isAnnotationPresent(Description.class)){
//            获取Description注解对象
            Description annotation = personClass.getAnnotation(Description.class);
//            获取注解的值
            System.out.println("类的描述 = " + annotation.value());

        }

        Method speak = personClass.getDeclaredMethod("speak");
        if(speak.isAnnotationPresent(Description.class)) {
            Description annotation = speak.getAnnotation(Description.class);
            System.out.println("方法的描述 = " + annotation.value());

        }
    }
}
